<?php

namespace Controller\UC;

class Pager extends \Lib\Core\Controller {

	public function actionIndex() {
		$pager = $this->getUCParam('pager');
		$size = 7;
		$pageCount = $pager->pageCount;
		$page = $pager->currentPage;
		$mid = ceil($size / 2) - 1;
		$start = $page - $mid;
		if ($start < 1) {
			$start = 1;
		}
		$end = $start + $size - 1;
		if ($end > $pageCount) {
			$end = $pageCount;
		}
		$this->assign('start', $start);
		$this->assign('uri', $pager->uri);
		$this->assign('scriptFunc', $pager->scriptFunc);
		$this->assign('end', $end);
		$this->assign('pager', $pager);
		$this->display();
	}
}